package com.jackchong.base

import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Lifecycle
import com.jackchong.net.JBaseData
import com.uber.autodispose.AutoDispose
import com.uber.autodispose.AutoDisposeConverter
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider

/**
 * author : jack(黄冲)
 * e-mail : 907755845@qq.com
 * create : 2020/8/6
 * desc   :
 */
abstract class KtFragment : BaseSupportFragment(), BaseView {


    private var hasLoad = false
    private var hasVisible = false

    override fun showLoading() {
        JWindow.showLoading(activity as AppCompatActivity)
    }

    override fun hideLoading() {
        JWindow.hideLoading()
    }


    override fun onFill(bean: JBaseData<*>) {

    }

    override fun onError(cause: Throwable) {

    }


    open fun onLazyInitView(){

    }

    override fun lifecycle(): Lifecycle = lifecycle

    override fun <T> bindAutoDispose(): AutoDisposeConverter<T> = AutoDispose.autoDisposable(
        AndroidLifecycleScopeProvider
            .from(this, Lifecycle.Event.ON_DESTROY))
}